//
//  Data_Object.h
//  MacStockApp
//
//  Created by 英傑 翁 on 12/2/13.
//  Copyright (c) 2012年 翁英傑. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DMPara.h"


@class Data_Model;


//標記：壓縮資料 陣列內的物件也要有壓縮協定

@interface Data_Object : NSObject<NSCoding>{
          
    
    NSMutableArray *his_data_serial;       //存放 日 歷史資料序列 以此為主要的資料序列
    NSMutableArray *his_data_serial_week;  //存放 週 歷史資料序列 尚未建制
    NSMutableArray *his_data_serial_month; //存放 月 歷史資料序列 尚未建制    
    
    
    NSMutableDictionary *table_data; //存放報價表欄位資料的字典
    
    NSNumber *his_data_high;  
    NSNumber *his_data_low; 
    
    NSDate *his_data_get_date; //取得歷史資料時間     
    NSString *Path_history_serial_write_to_catch_plist; //歷史資料序列寫入catches檔案路徑
    NSString *Path_history_serial_write_to_catch_arch; //歷史資料序列寫入catches檔案路徑    
    
    
    //最後一筆時間序列暫存 此段程式會讓選的股票越多記憶體會越增加
    NSMutableDictionary *last_dic_indicator; //指標數值
    NSMutableDictionary *last_dic_signal;    //訊號數值
    NSMutableDictionary *last_dic_profit;    //獲利數值
    NSMutableDictionary *last_dic_temp;      //暫存檔
  
    Data_Model *delgete_m;
    
    
    DMPara *data_object_para;//參數物件
    
    NSMutableDictionary *para; //參數
    
    BOOL isUseAdjClose;//是否以調整後收盤價當作收盤價
    
}
@property (retain)  DMPara *data_object_para;
@property (retain)  NSDate *his_data_get_date;       //取的歷史資料時間 在固定時間內取出之後 就可以不用再去下載或是檢查



//時間序列的存取
-(NSMutableArray *) get_his_data_serial;
 

-(void)save_calcuate_his_data_serial:(NSMutableArray *)hisDa reforce_calculate_all:(BOOL)reforce_calculate_all delgete_model:(Data_Model *)delgete_model ;

//歷史資料序列取出某一筆某一代號資料

-(id)get_his_data_serial_forkey:(NSString *)key index_before:(int)index_before HIS_dic_key:(NSString *)   HIS_dic_key;
//歷史資料序列取出最後一筆某一代號資料

-(id)get_last_his_data_serial_forkey:(NSString *)key HIS_dic_key:(NSString *) HIS_dic_key;
-(id)get_last_his_data_serial_forkey:(NSString *)key HIS_dic_key:(NSString *) HIS_dic_key index_before:(int)index_before;

//歷史資料序列取出某一欄位的所有資料
-(id)get_single_column_all_his_data:(NSMutableDictionary *)columndata;

//重新計算所有歷史資料序列計算
-(void)re_calculate_history_indicator_signal;

@property (retain)  NSNumber *his_data_high;
@property (retain)  NSNumber *his_data_low;
@property (retain)  NSMutableDictionary *table_data;


- (id)init_data:(NSMutableDictionary *)dic_data datamodel:(Data_Model *)dm _calculate_property_all:(NSMutableDictionary *)_calculate_property_all;
 
//計算方法函數 MA
-(void)calculateFunction_MA:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;

//計算方法函數 KD
-(void)calculateFunction_KD:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;

//計算方法函數 MACD
-(void)calculateFunction_MACD:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;

//計算方法函數 LF
-(void)calculateFunction_LF:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;

//計算方法函數 LFMESA
-(void)calculateFunction_LFMESA:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;



//計算方法函數 MESA
-(void)calculateFunction_MESA:(NSString *)calculate_key fhisDa:(NSMutableArray *)fhisDa index:(int)i fdic_indicator:(NSMutableDictionary *)fdic_indicator fdic_signal:(NSMutableDictionary *)fdic_signal fdic_temp:(NSMutableDictionary *)fdic_temp fdic_profit:(NSMutableDictionary *)fdic_profit;

//進行最佳化
-(void)run_optimize:(NSString *)optimize_method;

@end
